<template>
	<view class="page index">
		<view class="form">
			<common-input
			  title="原密码" 
				placeholder="请填写原密码" 
				v-model="oldPassword"
				:border-bottom="false"
			>
			</common-input>
			<common-input
			  title="新密码" 
				placeholder="请填写新密码" 
				v-model="newPassword"
				:border-bottom="false"
			>
			</common-input>
			<common-input
			  title="确认新密码" 
				placeholder="请再次填写新密码" 
				v-model="confirmPassword"
			>
			</common-input>
		</view>
		<view class="notice">
			  如忘记原密码，请联系管理员重置密码
		</view>
		<view class="footer">
			<button @click="save">提交</button>
		</view>
	</view>
</template>

<script>
	import commonInput from "@/components/commonInput.vue";
	import updateFile from "@/components/updateFile.vue";
	import {updateUserPwd} from "@/api/system/user.js"
	export default{
		data() {
			return{
				oldPassword: '',
				newPassword: '',
				confirmPassword:''
			}
		},
		components: {
			commonInput,
			updateFile
		},
		methods:{
			save(){
				if(this.oldPassword == ''){
					uni.showToast({
						icon: 'none',
						title: '原密码不能为空'
					})
					return;
				}
				if(this.newPassword == ''){
					uni.showToast({
						icon: 'none',
						title: '新密码不能为空'
					})
					return;
				}
				if(this.confirmPassword == ''){
					uni.showToast({
						icon: 'none',
						title: '确认密码不能为空'
					})
					return;
				}
				if(this.newPassword != this.confirmPassword){
					uni.showToast({
						icon: 'none',
						title: '两次输入密码不一致'
					})
					return;
				}
				updateUserPwd(this.oldPassword, this.newPassword).then((res) => {
					uni.showToast({
						icon: 'none',
						title: '修改成功'
					})
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/common/style/customicons.scss";
	.index{
		padding: 24rpx 0;
		@include flex-c;
		.form{
			.text{
				border-bottom: 4rpx #e5e5e5 solid;
				padding: 12rpx 30rpx;
				.title{
					font-size: 28rpx;
					color: #101010;
					padding: 0 0 16rpx;
					display: flex;
					align-items: center;
					.require{
					  height: 28rpx;
					  width: 6rpx;
					  background-color: #c24135;
					  margin-left: 10rpx;
				  }
				}
				textarea{
					font-size: 28rpx;
					color: #909090;
					height: 125rpx;
				}
				.place{
					font-size: 28rpx;
					color: #909090;
				}
			}
			&::-webkit-scrollbar{
				display: none;
			}
		}
		.notice{
			margin: 24rpx 30rpx;
			height: 52rpx;
			line-height: 52rpx;
			background-color: #DE868F;
			border-radius: 6rpx;
			color: #fff;
			font-size: 28rpx;
			padding: 0 30rpx;
		}
		.footer{
			margin: 300rpx 0 0;
			padding: 24rpx 30rpx;
			@include flex-r-between-start;
			button{
				@include button;
				color: #fff;
				height: 60rpx;
				width: 100%;
				background-color: #198AFA;
				line-height: 60rpx;
				font-size: 28rpx;
			}
		}
	}
</style>